package com.hmall.web;



import com.hmall.dto.ItemDoc;
import com.hmall.dto.PageDTO;
import com.hmall.dto.RequestParams;
import com.hmall.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("suggestion")
    public List<String> getSuggestions(@RequestParam("key") String key) {
        return searchService.getsuggestions(key);
    }

    @PostMapping("filters")
    public Map<String,List<String>> getFilters(@RequestBody RequestParams params){
        return searchService.getFilters(params);
    }

    @PostMapping("list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params){
        return searchService.search(params);
    }
}
